{extend name="public/base"/}
{block name="body"}
<title>简介与使命</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 后台管理 <span class="c-gray en">&gt;</span>关于我们<span class="c-gray en">&gt;</span> 简介与使命<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<article class="page-container">
		<form class="form form-horizontal section" id="form-admin-add">
			<section>
					<input type="hidden" class="input-text" value="{$data.id}" id="id" name="id">
					<div class="row cl">
						<label class="form-label col-xs-3 col-sm-2">英文标题：</label>
						<div class="formControls col-xs-8 col-sm-9">
							<input type="text" class="input-text" value="{$data.title}" id="title" name="title">
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-3 col-sm-2">副标题：</label>
						<div class="formControls col-xs-8 col-sm-9">
							<input type="text" class="input-text" value="{$data.subtitle}" id="subtitle" name="subtitle">
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-3 col-sm-2">简介详情：</label>
						<div class="formControls col-xs-8 col-sm-9">
							<script id="editor" name="intro_detail" type="text/plain" style="width:100%;height:400px;">{:htmlspecialchars_decode($data.intro_detail)}</script>
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-3 col-sm-2">企业文化背景图：</label>
						<div class="formControls col-xs-8 col-sm-9">
			                <div style="position:relative;" id="drop_area"></div>
			                <p style="color:#ccc;font-size:12px;">建议尺寸宽高:1920*570</p>
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-3 col-sm-2">企业文化标题：</label>
						<div class="formControls col-xs-8 col-sm-9">
							<input type="text" class="input-text" value="{$data.culture_title}" id="culture_title" name="culture_title">
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-3 col-sm-2">企业文化副标题：</label>
						<div class="formControls col-xs-8 col-sm-9">
							<input type="text" class="input-text" value="{$data.culture_subtitle}" id="culture_subtitle" name="culture_subtitle">
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-3 col-sm-2">愿景：</label>
						<div class="formControls col-xs-8 col-sm-9">
							<input type="text" class="input-text" value="{$data.our_vision}" id="our_vision" name="our_vision">
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-3 col-sm-2">使命：</label>
						<div class="formControls col-xs-8 col-sm-9">
							<input type="text" class="input-text" value="{$data.our_mission}" id="our_mission" name="our_mission">
						</div>
					</div>
			</section>

			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-3 col-sm-offset-2">
					<input id="submit" class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
				</div>
			</div>
		</form>
		
</article>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/static/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="/static/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="/static/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="/static/lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="/static/lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
<script type="text/javascript" src="/static/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="/static/js/upload.js"></script>
<script type="text/javascript">
var formData = new FormData();
var culture_bgimg;
$(function(){
	$('#drop_area div img').attr('src','{$data.culture_bgimg}');
	$('#drop_area div img').attr('onerror',"javascript:this.src='/static/img/upload.png'");
	if($("#drop_area div img").attr('src')=='/static/img/upload.png'){
		culture_bgimg='';
	}else{
		culture_bgimg= `{$data.culture_bgimg}`;
	}
	var ue = UE.getEditor('editor');
});
var dragImgUpload = new DragImgUpload("#drop_area",{
    callback:function (files) {
        //回调函数，可以传递给后台等等
        if(files[0].size<3145728){
	        var file = files[0];
	        formData.append("file",file);
        }else{
        	alert('出错');
        	location.replace(location.href);
        }
    }
});
$("#submit").click(function() {
	layer.load(1, {
	  shade: [0.1,'#fff'] //0.1透明度的白色背景
	});
	var id=$("input[name=id]").val();
	var title=$("input[name=title]").val();
	var subtitle=$("input[name=subtitle]").val();
	var culture_title=$("input[name=culture_title]").val();
	var culture_subtitle=$("input[name=culture_subtitle]").val();
	var our_vision=$("input[name=our_vision]").val();
	var our_mission=$("input[name=our_mission]").val();
	var intro_detail=UE.getEditor('editor').getContent();
	if(formData.get("file")){
		if(formData.get("file")){
			console.log(1)
			$.ajax({
		          type: 'POST',
		          url: "{:url('uploadtmd')}",
		          data:formData,
		          async:false,
		          contentType: false, /*不可缺*/
		          processData: false, /*不可缺*/
		          success: function(response){
		            if(response.code==200){
		            	culture_bgimg=response.photo;
		            }
		          },
		          error: function(err){
		          	console.log('formData'+err)
		          }
		    })
		}
		
	    $.ajax({
		    type: 'POST',
	        async:false,
		    url: "{:url('intro_mission')}",
		    data: {id:id,title:title,subtitle:subtitle,culture_title:culture_title,culture_subtitle:culture_subtitle,our_vision:our_vision,our_mission:our_mission,intro_detail:intro_detail,culture_bgimg:culture_bgimg},
		    success: function(resdata){
		        if(resdata.code==200){
					layer.msg(resdata.msg,{icon:1,time:1000});
					setTimeout("parent.location.reload()",1000);
		        }else{
					layer.msg(resdata.msg,{icon:2,time:3000});
		        }
		    },
		    error: function(){
				layer.msg('数据保存失败',{icon:2,time:3000});
		    }
		})
	}else{
		$.ajax({
		    type: 'POST',
		    url: "{:url('intro_mission')}",
		    data: {id:id,title:title,subtitle:subtitle,culture_title:culture_title,culture_subtitle:culture_subtitle,our_vision:our_vision,our_mission:our_mission,intro_detail:intro_detail,culture_bgimg:culture_bgimg},
		    success: function(resdata){
		        if(resdata.code==200){
					layer.msg(resdata.msg,{icon:1,time:1000});
					setTimeout("location.reload()",1000);
		        }else{
					layer.msg(resdata.msg,{icon:2,time:3000});
		        }
		    },
		    error: function(){
				layer.msg('数据保存失败',{icon:2,time:3000});
		    }
		})
	}
	
    
})
</script> 

{/block}